﻿using System.Windows.Controls;
using TicTacToe.Core;
using System.Windows.Media;

namespace _3DTicTacToe.UI.Components
{
    partial class PlayerPanel : UserControl
    {
        public PlayerPanel()
        {
            InitializeComponent();
        }

        public void UpdatePanel(Player nextPlayer)
        {
            playerBorder.Background = nextPlayer.Color.CreateBrush();
            playerControl.Foreground = nextPlayer.Color.Invert().CreateBrush();
            playerControl.Content = nextPlayer.Name;
        }

        public void UpdatePanelForGameOver(Player winner)
        {
            if (winner != null)
            {
                playerBorder.Background = winner.Color.CreateBrush();
                playerControl.Foreground = winner.Color.Invert().CreateBrush();
                playerControl.Content = winner.Name + " wins!";
            }
            else
            {
                playerBorder.Background = Brushes.Black;
                playerControl.Foreground = Brushes.White;
                playerControl.Content = "Draw! You're all Losers!";
            }
        }
    }
}
